<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //设置cookie
        function setCookie(name, value, expires) {
            var cookie_str = name + '=' + value;
            //判定是否要设置过期时间
            if (typeof expires === 'number') {
                var d = new Date();
                d.setDate(d.getDate() + expires);
                cookie_str += ';expires' + d;
            }
            document.cookie = cookie_str;
        }
           var res= setCookie('大连忙','789',7)
        //     console.log(res);

        //cookie.html:13 username=dada; password=123456; 
        //__guid=111872281.4148287127900956000.1587388614907.4265
        // 获取cookie
        function getCookie(name) {
            var cookie_arr = document.cookie.split(';')
            for (var i = 0; i < cookie_arr.length; i++) {
                var cookie_item = cookie_arr[i]
                cookie_item = cookie_item.split('=')
                if (cookie_item[0] == name) {
                    return cookie_item[1]
                }
            }
            return ''
        }
        //删除cookie
        function removeCookie(name) {
            setCookie(name, "", -1);
        }

        // removeCookie("data")
    </script>
</body>

</html>